using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for ControlProviders
/// </summary>
public class ControlProviders
{
    public ControlProviders()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    private string errorMessage = "";
    public string ErrorMessage
    {
        set { errorMessage = value; }
        get { return errorMessage; }
    }
    public int FillRecruiterAccount(DataList DataList1, int startRecord, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SqlServerProvider cls = new SqlServerProvider(connectionString);
            cls.CommandText = "select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts"; 
            cls.CommandType = CommandType.Text;
            DataTable dataTable = cls.GetDataTable( startRecord, maxRecord);
            totalRecord = dataTable.Rows.Count;
            DataList1.DataKeyField = "RecruiterID";
            DataList1.DataSource = dataTable;
            DataList1.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
    public int FillRecruiterAccount(DataList DataList1, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string querySelect = "select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts";
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SqlServerProvider cls = new SqlServerProvider(connectionString);
            cls.CommandText = querySelect;
            cls.CommandType = CommandType.Text;
            DataTable dataTable = cls.GetDataTable( 0, maxRecord);
            querySelect = "select count(*) from tblRCAccounts";
            cls.CommandText = querySelect;
            cls.CommandType = CommandType.Text;
            totalRecord = cls.GetOneValue();
            DataList1.DataKeyField = "RecruiterID";
            DataList1.DataSource = dataTable;
            DataList1.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
    public int FillRecruiterAccount(Repeater repeater, int startRecord, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SqlServerProvider cls = new SqlServerProvider(connectionString);
            cls.CommandText = "select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts";
            DataTable dataTable = cls.GetDataTable(  startRecord, maxRecord);
            totalRecord = dataTable.Rows.Count;

            repeater.DataSource = dataTable;
            repeater.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
    public int FillRecruiterAccount(Repeater repeater, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string querySelect = "select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts";
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SqlServerProvider cls = new SqlServerProvider(connectionString);
               cls.CommandText = querySelect;
            DataTable dataTable = cls.GetDataTable(  0, maxRecord);
            querySelect = "select count(*) from tblRCAccounts";
            cls.CommandText = querySelect;
            totalRecord = cls.GetOneValue( );

            repeater.DataSource = dataTable;
            repeater.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
}
